package com.db.sql;

import java.util.Map;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;



public class SqlMapFactory {
	// 单例模式 start
	private volatile static SqlMapFactory instance = null;
	private Map<String,String> sqlMap;

	private SqlMapFactory() {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"sql-map.xml");
		SqlMap data = (SqlMap) context.getBean("SqlMap");
		this.sqlMap =  data.getSqlMap();
		

	}

	public static SqlMapFactory getInstance() {
		if (instance == null) {
			synchronized (SqlMapFactory.class) {// 1
				if (instance == null) {// 2
					instance = new SqlMapFactory();// 3
				}
			}
		}
		return instance;
	}
	// 单例模式 end

	public Map<String, String> getSqlMap() {
		return sqlMap;
	}
	
	

}
